// #define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x<0) putchar('-'), x*=-1;
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
using namespace std;
#define DEBUG
const int N=1e6+10;
string A, B;
int n, m;
int nxt[N];
void init()
{
    cin >> A >> B;
    n=A.size(), m=B.size();
    A=' '+A; B=' '+B;
}

void MakeNext()
{
    int i=1, j=0;
    nxt[1]=0;
    for(; i<n; i++)
    {
        if(j==0||A[i]==B[j])
        {
            ++i, ++j;
            nxt[i]=j;
        }
        else{ //匹配失败，返回到(经KMP优化已经匹配过)未匹配点
            j=nxt[j];
        }
    }
}

int KMP() //返回首个匹配的下标
{
    int i=1, j=1;
    while(i<=n&&j<=m)
    {
        if(j==0||A[i]==B[j]) //没有匹配或者当前点匹配
            ++i, ++j;
        else j=nxt[j]; //模式串向右滑动
    }
    if(j>m) return i-m;
    else return 0;
}

void solve()
{
    init();
    MakeNext();
    
    cout << KMP() << endl;
    
    for(int i=0; i<m; i++)
        printf("%d ", nxt[i]);
    cout << endl;
}

// #undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        // freopen("./out.txt", "w", stdout);
    #endif
    #ifndef quickread
    // ios::sync_with_stdio(0);
    // cin.tie(0); cout.tie(0);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}
